#ifndef JOBSCHEDULER_H
#define JOBSCHEDULER_H

namespace bimar_scheduler_lib
{

class CJobThreadPoolProcess : public CGThreadPoolProcess
{
public:
  CJobThreadPoolProcess(CTask *task) : m_task(task) {}; 

  /* CGThreadPoolProcess overrides */
  gulong RunProcess();

protected:
  CTask *m_task;
};

class CJobScheduler : public CGThreadWrapper
{
public:
  CJobScheduler(gboolean taskOwner);
  virtual ~CJobScheduler();

  gboolean Create();
  gboolean Destroy();
  gboolean PushBack(CTask *task); 
  gboolean PushBack(CJob *job);

  gboolean Start();
  gboolean Stop();
  gboolean Pause();
  gboolean Resume();
  gboolean Abort();
  gboolean WaitJobDone(gulong milis = WAIT_INFINITE);

protected:
  gboolean BindTasks();
  
  /* CGThreadWrapper overrides */
  gulong RunThread();

protected:
  CJob *m_job;							//!< the JOB (owner)
  CGThreadPoolWrapper m_threadPool;		//!< thread pool
  glong m_doneJobs;						//!< num done jobs
};

}; /* namespace */

#endif
